package com.web.spider.youku.start;

import com.web.spider.youku.entity.Page;
import com.web.spider.youku.service.IDownloadService;
import com.web.spider.youku.service.IProcessService;
import com.web.spider.youku.service.impl.HttpClientDownloadService;
import com.web.spider.youku.service.impl.YouKuProcessService;

/**
 * @author cherrish
 * @name StartTVCount
 * @date 2019/4/6 18:05
 * @desc TODO
 */
public class StartTVCount {
    private IDownloadService downloadService;
    private IProcessService processService;

    public StartTVCount(IDownloadService downloadService, IProcessService processService) {
        this.downloadService = downloadService;
        this.processService = processService;
    }

    public static void main(String[] args) {
        StartTVCount tv = new StartTVCount(new HttpClientDownloadService(),
                new YouKuProcessService());
        String url = "https://list.youku.com/show/id_z9cd2277647d311e5b692.html?spm=a2h0k.11417342.soresults.ddetail";
        Page page = tv.downloadPage(url);
        tv.processPage(page);
        //System.out.println(page.getContent());
    }
    public Page downloadPage(String url){
        return downloadService.download(url);
    }
    public void processPage(Page page){
        processService.process(page);
    }
}
